package cn.edu.jxust.common.domain.web.api.area;

import cn.edu.jxust.common.domain.dto.AreaVo;
import cn.edu.jxust.common.response.Result;
import cn.edu.jxust.core.infrastructure.util.Const;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author QiuKangming
 * @version 1.0
 * @description
 * @since 2020/09/15 14:44
 */

@RequestMapping("/api/area")
@RequiresRoles(value = {Const.SUPER_ADMIN, Const.BUREAU_ADMIN}, logical = Logical.OR)
public interface IAreaController {

    /**
     * 增加区域信息
     * @param areaVo 区域视图对象
     * @param result 绑定结果集
     * @return Result
     */
    @PostMapping
    @RequiresPermissions("area:add")
    Result addArea(@RequestBody @Validated AreaVo areaVo, BindingResult result);

    /**
     * 根据 id 删除区域信息
     * @param id 区域id号
     * @return Result
     */
    @DeleteMapping("/{id}")
    @RequiresPermissions("area:del")
    Result delArea(@PathVariable("id") Integer id);

    /**
     * 批量删除 区域信息, 根据 areaIds
     * @param areaIdsStr 区域id号组成的is字符串, 以 , 分割
     * @return Result
     */
    @DeleteMapping("/batch")
    @RequiresPermissions("area:del")
    Result delAreaBatch(@RequestParam @Validated String areaIdsStr);

    /**
     * 修改区域信息
     * @param areaVo 视图对象
     * @param result 绑定结果
     * @return Result
     */
    @PutMapping
    @RequiresPermissions("area:edit")
    Result modifyArea(@RequestBody AreaVo areaVo, BindingResult result);

    /**
     * 获取区域信息列表
     * @param page 第几页
     * @param size 一页几条数据
     * @return Result
     */
    @GetMapping
    @RequiresPermissions("area:list")
    Result findAreaPage(@RequestParam(value = "page", defaultValue = Const.DEFAULT_PAGE_NUMBER) Integer page,
                        @RequestParam(value = "size", defaultValue = Const.DEFAULT_PAGE_SIZE) Integer size);

    /**
     * 获取所有区域信息
     * @return Result
     */
    @GetMapping("/list")
    @RequiresPermissions("area:list")
    Result findAreaList();

}
